/*
 * Copyright 2003-2007 (c) Live Media Pty Ltd. <argot@einet.com.au> 
 *
 * This software is licensed under the Argot Public License 
 * which may be found in the file LICENSE distributed 
 * with this software.
 *
 * More information about this license can be found at
 * http://www.einet.com.au/License
 * 
 * The Developer of this software is Live Media Pty Ltd,
 * PO Box 4591, Melbourne 3001, Australia.  The license is subject 
 * to the law of Victoria, Australia, and subject to exclusive 
 * jurisdiction of the Victorian courts.
 */

package com.colony.channel.types;

import java.io.IOException;

import com.argot.TypeException;
import com.argot.TypeOutputStream;
import com.argot.TypeWriter;
import com.argot.network.TypeEndPoint;
import com.colony.channel.ChannelClient;
import com.colony.channel.ChannelIdentifier;

public class ChannelPipeClientWriter
implements TypeWriter
{
	private ChannelClient _client;
	
	public ChannelPipeClientWriter( ChannelClient client )
	{
		_client = client;
	}

	public void write( TypeOutputStream out, Object o ) 
	throws TypeException, IOException
	{
		TypeEndPoint tep = (TypeEndPoint) o;
		ChannelIdentifier cid = _client.connectSendStream(tep.getInputStream(),tep.getOutputStream());
		out.writeObject(ChannelIdentifier.TYPENAME, cid );	
	}
}
